package draw;


import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JPanel;
import javax.swing.Timer;

public class GraphView extends JPanel {

	private PhysicalGraph graph;
	private Timer timer;
	
	public GraphView(PhysicalGraph graph2) {
		graph = graph2;
		setPreferredSize(new Dimension(900, 900));
		setMinimumSize(new Dimension(900, 900));
		timer = new Timer(10, new TimeListener());
		timer.start();
	}

	public void run(){
		graph.run();
		repaint();
	}
	
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		graph.draw(g);
	}
	
	private class TimeListener implements ActionListener {

		public void actionPerformed(ActionEvent arg0) {
			run();
		}

	}

}
